#include <stdio.h>

int avg(int row, int r[ ][3]);

int main(void)
{
	int a[2][3] = {{1, 3, 5}, {2, 4, 6}};
	int b[3][3] = {{1, 4, 7}, {2, 5, 8}, {3, 6, 9}};
	
	printf("avg_a = %d\n", avg(2, a));
	printf("avg_b = %d\n", avg(3, b));
	
	return 0;
}

int avg(int row, int r[ ][3])
{
	int i, j, sum = 0, n = 0;

	for (i = 0; i < row; i++)
		for (j = 0; j < 3; j++)
		{
			sum += r[i][j];
			n++;
		}

	return sum / n;
}